﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using PlanningGIS.Framework;
using PlanningGIS.Util.Configurations;
using PlanningGIS.Win.Controls;

namespace PlanningGIS.DataCheck
{
    /// <summary>
    /// 
    /// </summary>
    public class DataCheckHelper
    {
        /// <summary>
        /// 规则文件路径
        /// </summary>
        private static string rulesXml = AppConfig.ConfigPath + "\\Rule.xml";

        /// <summary>
        /// 规则文件中配置的所有规则
        /// </summary>
        private static DataCheck _DataCheck = null;

        /// <summary>
        /// 获取规则文件中配置的所有规则
        /// </summary>
        public static DataCheck DataCheck
        {
            get
            {
                if (_DataCheck == null)
                {
                    if (File.Exists(rulesXml) == false)
                    {
                        MsgHelper.ShowErrorMsgbox("规则文件[" + rulesXml + "]未找到，请检查参数及配置文件。");
                        return null;
                    }
                    _DataCheck = ConfigurationHelper.GetObjectFromXml<DataCheck>(rulesXml);
                }
                return _DataCheck;
            }
        }

    }
}
